package com.mini.cn.goods.controller;

import com.mini.cn.goods.po.GoodsInfo;
import com.mini.cn.goods.po.dto.GoodsInfoDto;
import com.mini.cn.goods.po.dto.GroupDesDto;
import com.mini.cn.goods.service.GroupGoodsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * User: fly
 * Date: 2022/11/19
 * Time: 17:59
 */
@CrossOrigin(origins = "*", maxAge = 3600)
@Controller
public class GroupGoodsController {

    @Autowired
    GroupGoodsService groupGoodsService;

    @RequestMapping(value = "/getGroupGoods", method = RequestMethod.GET, params = {"appid", "openid"})
    @ResponseBody
    public SupplyMap getAllGroupGoods(int appid, String openid) {
        SupplyMap supplyMap = new SupplyMap();
        GroupDesDto groupDto = groupGoodsService.getAllGroupGoods(appid, openid);
        supplyMap.put("data", groupDto);
        return supplyMap;
    }

    private void copy(GoodsInfo goodsInfo, GoodsInfoDto goodsInfoDto) {
        BeanUtils.copyProperties(goodsInfo, goodsInfoDto);
    }
}
